package cn.qingyun.gis.modules.init.utils;

import cn.qingyun.gis.modules.init.system.vo.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;

@Slf4j
public class ShiroUtil {

    /**
     * 获取后台登录用户信息
     *
     * @return
     */
    public static LoginUser getLoginUser() {
        LoginUser sysUser;
        try {
            sysUser = SecurityUtils.getSubject().getPrincipal() != null ? (LoginUser) SecurityUtils.getSubject().getPrincipal() : null;
        } catch (Exception e) {
            log.error("ShiroUtil.getLoginUser error", e);
            sysUser = null;
        }
        return sysUser;
    }
}
